<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>系统常态化运行评分系统</title>
    <link rel="stylesheet" href="../../component/pear/css/pear.css" />
    <style>
        .expand.pear-btn:hover {
            color: currentColor;
            background: none;
        }

        .expand.pear-btn {
            border: 1px solid rgba(255, 255, 255, 0)
        }
        .layui-table-box button {
            font-size: 12.5px !important;
        }
    </style>
</head>

<body class="pear-container">
    <div class="layui-card">
        <div id="divCardHeader" class="layui-card-header">

        </div>
        <div class="layui-card-body">
            <table id="user-table" lay-filter="user-table"></table>
        </div>
    </div>


    <script type="text/html" id="user-bar">
    <button class="pear-btn pear-btn-primary pear-btn-xs" title="查看指标详情" lay-event="pf"><i
        class="layui-icon layui-icon-search"></i>指标详情</button>
   
</script>




    <script src="../../component/layui/layui.js"></script>
    <script src="../../component/pear/pear.js"></script>
    <script src="../../scripts/utils/request.js"></script>
    <script src="../../scripts/utils/auth.js"></script>
    <script>
        var $, table, form, drawer, popup, notice, laydate
        layui.use(['table', 'form', 'jquery', 'drawer', 'popup', 'notice', 'laydate'], function () {
            table = layui.table;
            form = layui.form;
            $ = layui.jquery;
            drawer = layui.drawer;
            popup = layui.popup;
            notice = layui.notice;
            laydate = layui.laydate;


            $("#divCardHeader").html(localStorage.getItem("mineName") + "—指标溯源维护")


            laydate.render({
                elem: '#checkTime'
            });

            table.render({
                id: "user-table",
                elem: '#user-table',
                url: baseURL + '/api/configZb/listSystem',
                method: 'post',
                contentType: 'application/json',
                page: false,
                loading: true,
                headers: {
                    token: localStorage.getItem("token")
                },
                request: {
                    pageName: 'pageIndex', // page
                    limitName: 'pageSize', // limit
                },
                where: {
                    mineId: $("#mineName").val()
                },
                cols: [[
                { type: 'numbers', title: '序号', width: 60 },
                    { field: 'systemName', minWidth: 150, title: '智能化系统名称' },

                    { field: 'totalScore', minWidth: 200, title: '系统总分' },
                    { field: 'weight', minWidth: 100, title: '权重' },
                    { title: '操作', templet: '#user-bar', width: 320, align: 'center' }
                ]],
                skin: 'grid',
                toolbar: false,
                defaultToolbar: [],
                done: function (res, curr, count) {
                    validToken(res);
                }
            });


            /**
             * 每行的按钮
             */
            table.on('tool(user-table)', function (obj) {
                if (obj.event === 'pf') {
                    parent.layui.admin.addTab('pf' + obj.data.systemName + obj.data.id, obj.data.systemName,
                     `/page/mine/systemDetails.html?id=${obj.data.id}&systemName=${obj.data.systemName}&totalScore=${obj.data.totalScore}&weight=${obj.data.weight}`)
                    parent.layui.admin.refresh('pf' + obj.data.systemName + obj.data.id);
                }
            });

            /**
             * 新增操作
             */
            table.on('toolbar(user-table)', function (obj) {
                if (obj.event === 'addPf') {
                    window.addPf();
                } else if (obj.event === 'refresh') {
                    window.refresh();
                }
            });

            form.on('submit(user-query)', function (data) {
                table.reload('user-table', {
                    where: data.field,
                })
                return false;
            });


            /**
             * 新增/修改评分
             */
            form.on('submit(lay-user-add)', function (data) {
                let reqData = data.field;
                if (!reqData.id || reqData.id == '') {
                    postAjax('/api/pf/add', reqData, function (response) {
                        drawer.closeAll();
                        table.reload('user-table');
                    }, null);
                } else {
                    postAjax('/api/pf/modify', reqData, function (response) {
                        drawer.closeAll();
                        table.reload('user-table');
                    }, null);
                }
            });


            window.refresh = function (param) {
                table.reload('user-table');
            };
        })
    </script>
</body>

</html>